/*----------------------------------------
	1.2.3) 站点设置
	----------------------------------------*/
	var Admin;
	if (!Admin) Admin = {};
	Admin.ss = {};

	/**
	 * main gui of site setting
	 */
	Admin.ss.main = function()
	{
		$(".content_block").spin();
		$.ajax({
			url: ss_path + "site_setting_form",
			success: function(html) {
				$(".content_block").spin(false);
				$(".content_block").html(html);
			}
		});
	}
	
	/**
	 * submit modify of site setting
	 * @param site_setting_array
	 */
	Admin.ss.submit_site_setting = function(site_setting_array)
	{
		$(".content_block").spin();
		$.ajax({
			url: ss_path + "site_setting_submit",
			dataType: 'json',
			data: {site_setting_array: site_setting_array},
			success: function(data) {
				$(".content_block").spin(false);
				$(".message").remove();
				if (data == 'succeeded') {
					$("caption").append(
						"<div class='message success'>" +
		                "<p><strong> 站点设置 </strong>保存成功</p>" +
		                "</div>"
					);
				} else if (data == 'failed') {
					$("caption").append(
						"<div class='message error'>" +
		                "<p><strong> 站点设置 </strong>保存失败</p>" +
		                "</div>"
					);
				}
			}
		});
	}
	
	// listen to 'submit site setting' button
	$(".ss#submit").live('click', function() {
		var is_empty = 0;
		$(":text").each(function() {
			if ($(this).val() == '') {
				alert("请填写'" + $(this).parent().prev().html() + "'");
				is_empty = 1;
				return false;
			}
		});
		$("textarea").each(function() {
			if ($(this).val() == '') {
				alert("请填写'" + $(this).parent().prev().html() + "'");
				is_empty = 1;
				return false;
			}
		});
		
		if (is_empty == 1) { return; }
		
		var site_setting_array = new Array();
		$(":text").each(function() {
			site_setting_array[$(this).attr("id")] = $(this).val();
		});
		$("textarea").each(function() {
			site_setting_array[$(this).attr("id")] = $(this).val();
		});
		
		Admin.ss.submit_site_setting(site_setting_array);
		setTimeout("$('.message').slideUp(200)", 3000);
	});